home *** CD-ROM | disk | FTP | other *** search
- Imports System.Data.SqlClient
- Public Class Cliente
- Public Key As String
- Public ondb As Boolean
- Private mIdCliente As Integer
- Private mRagioneSociale As String
- Private mPIvaCF As String
- Private mCitta As String
- Private mIndirizzo As String
- Private mCAP As Integer
- Private mCognome As String
- Private mNome As String
- Private mTelefono As String
- Private mFax As String
- Private mCellulare As String
- Private mProvincia As String
- Public Property IdCliente() As Integer
- Get
- IdCliente = mIdCliente
- End Get
- Set(ByVal Value As Integer)
- mIdCliente = Value
- End Set
- End Property
- Public Property RagioneSociale() As String
- Get
- RagioneSociale = mRagioneSociale
- End Get
- Set(ByVal Value As String)
- mRagioneSociale = Value
- End Set
- End Property
- Public Property PIvaCF() As String
- Get
- PIvaCF = mPIvaCF
- End Get
- Set(ByVal Value As String)
- mPIvaCF = Value
- End Set
- End Property
- Public Property Citta() As String
- Get
- Citta = mCitta
- End Get
- Set(ByVal Value As String)
- mCitta = Value
- End Set
- End Property
- Public Property Indirizzo() As String
- Get
- Indirizzo = mIndirizzo
- End Get
- Set(ByVal Value As String)
- mIndirizzo = Value
- End Set
- End Property
- Public Property CAP() As Integer
- Get
- CAP = mCAP
- End Get
- Set(ByVal Value As Integer)
- mCAP = Value
- End Set
- End Property
- Public Property Cognome() As String
- Get
- Cognome = mCognome
- End Get
- Set(ByVal Value As String)
- mCognome = Value
- End Set
- End Property
- Public Property Nome() As String
- Get
- Nome = mNome
- End Get
- Set(ByVal Value As String)
- mNome = Value
- End Set
- End Property
- Public Property Telefono() As String
- Get
- Telefono = mTelefono
- End Get
- Set(ByVal Value As String)
- mTelefono = Value
- End Set
- End Property
- Public Property Fax() As String
- Get
- Fax = mFax
- End Get
- Set(ByVal Value As String)
- mFax = Value
- End Set
- End Property
- Public Property Cellulare() As String
- Get
- Cellulare = mCellulare
- End Get
- Set(ByVal Value As String)
- mCellulare = Value
- End Set
- End Property
- Public Property Provincia() As String
- Get
- Provincia = mProvincia
- End Get
- Set(ByVal Value As String)
- mProvincia = Value
- End Set
- End Property
-
- Public Sub Salva()
- Dim sp As SqlCommand
- Dim spPar As SqlParameter
- Dim ObjReader As SqlDataReader
- Dim strSql As String
- If ondb = True Then
- strSql = "up_update_Cliente"
- Else
- strSql = "up_insert_Cliente"
- End If
- sp = New SqlCommand(strSql, ObjConnection)
- sp.CommandType = CommandType.StoredProcedure
- spPar = sp.Parameters.Add("@IdCliente", SqlDbType.Int, 4)
- spPar.Value() = IdCliente
- If ondb = False Then spPar.Direction = ParameterDirection.InputOutput
- spPar = sp.Parameters.Add("@RagioneSociale", SqlDbType.VarChar, 50)
- spPar.Value() = RagioneSociale
- spPar = sp.Parameters.Add("@PIVACF", SqlDbType.VarChar, 50)
- spPar.Value() = PIVACF
- spPar = sp.Parameters.Add("@Citta", SqlDbType.Char, 30)
- spPar.Value() = Citta
- spPar = sp.Parameters.Add("@Indirizzo", SqlDbType.Char, 100)
- spPar.Value() = Indirizzo
- spPar = sp.Parameters.Add("@CAP", SqlDbType.Int, 4)
- spPar.Value() = CAP
- spPar = sp.Parameters.Add("@Cognome", SqlDbType.VarChar, 50)
- spPar.Value() = Cognome
- spPar = sp.Parameters.Add("@Nome", SqlDbType.VarChar, 50)
- spPar.Value() = Nome
- spPar = sp.Parameters.Add("@Telefono", SqlDbType.VarChar, 20)
- spPar.Value() = Telefono
- spPar = sp.Parameters.Add("@Fax", SqlDbType.VarChar, 20)
- spPar.Value() = Fax
- spPar = sp.Parameters.Add("@Cellulare", SqlDbType.VarChar, 20)
- spPar.Value() = Cellulare
- spPar = sp.Parameters.Add("@Provincia", SqlDbType.Char, 2)
- spPar.Value() = Provincia
-
- Try
- ObjReader = sp.ExecuteReader()
- Catch e As Exception
- MsgBox(e.Message)
- Finally
- ObjReader.Close()
- End Try
- If ondb = False Then IdCliente = sp.Parameters.Item("@IdCliente").Value
- ondb = True
- End Sub
- Public Sub Cancella()
- If ondb = False Then Exit Sub
- Dim sp As SqlCommand
- Dim spPar As SqlParameter
- Dim ObjReader As SqlDataReader
- Dim strSql As String
- strSql = "up_delete_Cliente"
- sp = New SqlCommand(strSql, ObjConnection)
- sp.CommandType = CommandType.StoredProcedure
- spPar = sp.Parameters.Add("@IdCliente", SqlDbType.Int, 4)
- spPar.Value() = IdCliente
- Try
- ObjReader = sp.ExecuteReader()
- Catch e As Exception
- MsgBox(e.Message)
- Finally
- ObjReader.Close()
- End Try
- End Sub
- Public Sub Ricerca()
- Dim QuerySql As String
- QuerySql = "select * from Cliente where IdCliente=" & IdCliente
- Dim ObjCommand As New SqlCommand(QuerySql, ObjConnection)
- Dim ObjReader As SqlDataReader = ObjCommand.ExecuteReader()
- Try
- While ObjReader.Read()
- IdCliente = ObjReader.GetInt32(0)
- RagioneSociale = ObjReader.GetString(1)
- PIVACF = ObjReader.GetString(2)
- Citta = ObjReader.GetString(3)
- Indirizzo = ObjReader.GetString(4)
- CAP = ObjReader.GetInt32(5)
- Cognome = ObjReader.GetString(6)
- Nome = ObjReader.GetString(7)
- Telefono = ObjReader.GetString(8)
- Fax = ObjReader.GetString(9)
- Cellulare = ObjReader.GetString(10)
- Provincia = ObjReader.GetString(11)
- ondb = True
- End While
- Finally
- ObjReader.Close()
- End Try
- End Sub
-
- End Class
-